---
id: 6582507654b3ed5712341382
title: Step 29
challengeType: 20
dashedName: step-29
---

# --description--

You are going to use conditional statements to check the user's choice. If the choice is `'1'`, it means the user wants to add an expense.

Still in the `while` loop, under the `choice` variable, write an `if` statement to check if `choice` equals the string `'1'`. If it's true, it will be the starting point for adding a new expense.

Inside the `if` statement body, declare a variable `amount` and assign it an empty `input()` call.

# --hints--

You should have `if choice == '1':` in your `while` loop:

```js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");        
    const foo = __helpers.python.getDef("\n"+transformedCode, "main");
    const {function_body} = foo;    
    assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:/m));
  }
})
```

You should have `amount = input()` in your `if` statement body:

```js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");        
    const foo = __helpers.python.getDef("\n"+transformedCode, "main");
    const {function_body} = foo;    
    assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*input\s*\(\s*\)/m));
  }
})
```

# --seed--

## --seed-contents--

```py
def add_expense(expenses, amount, category):
    expenses.append({'amount': amount, 'category': category})
    
def print_expenses(expenses):
    for expense in expenses:
        print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
    
def total_expenses(expenses):
    return sum(map(lambda expense: expense['amount'], expenses))
    
def filter_expenses_by_category(expenses, category):
    return filter(lambda expense: expense['category'] == category, expenses)
    
--fcc-editable-region--
def main():
    expenses = []
    while True:
        print('\nExpense Tracker')
        print('1. Add an expense')
        print('2. List all expenses')
        print('3. Show total expenses')
        print('4. Filter expenses by category')
        print('5. Exit')
        
        choice = input('Enter your choice: ')

--fcc-editable-region--
```
